﻿library(R.NET)

engine <- REngine$GetInstace()

countA <- function(filePath, letter)
{

text <- readLines(filePath)

# Convert the text to lowercase
text <- tolower(text)

# Count the number of times "a" appears in the text
count_a <- sum(gregexpr(letter, text)[[1]] > 0)

return(count_a)
}
engine$ParseAndEval(countA)
countARef <- engine$GetSymbol("countA")
engine$CreateDLL("countA.dll", list(countARef))